package com.magina.mq.rabbit.exchange.topic;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@RabbitListener(
        bindings=@QueueBinding(
                value = @Queue(value = "${rab.mq.config.queue.logs}",autoDelete="true"),
                exchange =@Exchange(value = "${rab.mq.config.exchange}",type =ExchangeTypes.TOPIC),
                key = "*.log.*"
        )
)
public class LogsReceiver {

    @Value("${rab.mq.config.queue.logs}")
    private String logsTopicQueueName;

    @RabbitHandler
    public void process(String msg){
        String resultStr  = "RabbitMq:"+logsTopicQueueName+" consumer 收到一条信息: " + msg;
        System.out.println( resultStr);
    }

}
